'use strict';
exports = module.exports = function ($scope){
    $scope.list = `
                懒人图库
                www.lanrentuku.com
                www.nifengla.com
                www.lanrentuku.com
                懒人图库
                www.maitianquan.com
                www.lanrentuku.com
                zheye.cc
                www.nifengla.com
                www.maitianquan.com
                zheye.cc
                懒人图库
                www.lanrentuku.com
    `
    $scope.process = function (){
        var list = $scope.list;
        var arr = list.split('\n');
        arr = unique(arr);
        list = "";
        for(var key in arr){ list += arr[key] + '\n'; }
        $scope.list = list
    }
    function unique(ary) {
        var i = 0, gid='_'+(+new Date)+Math.random(), objs = [], hash = { 'string': {}, 'boolean': {}, 'number': {} }, p, l = ary.length, ret = [];
        for (; i < l; i++) {
            p = ary[i];
            if (p == null) continue;
            var tp = typeof p;
            if (tp in hash) { if (!(p in hash[tp])) { hash[tp][p] = 1; ret.push(p); } }
            else { if (p[gid]) continue; p[gid]=1; objs.push(p); ret.push(p); }
        }
        for(i=0,l=objs.length;i<l;i++) { p=objs[i]; p[gid]=undefined; delete p[gid]; }
        return ret;
    }
}
